﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ChinaDynastyTours.Views
{
    public partial class SplashForm : Form
    {
        private Form MainForm;

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="SplashForm" /> class.
        /// </summary>
        public SplashForm(Form mainForm)
        {
            InitializeComponent();

            // Store the reference to parent form
            MainForm = mainForm;

            this.Location = new Point(MainForm.Location.X + (MainForm.Width - this.Width) / 2, MainForm.Location.Y + (MainForm.Height - this.Height) / 2);

            this.Owner = mainForm;
            this.ShowInTaskbar = false; // do not show form in task bar
            this.TopMost = true; // show splash form on top of main form
            this.StartPosition = FormStartPosition.Manual;
            this.Visible = false;
        }

        #endregion

        #region Methods

        public void ShowSplash(string text)
        {
            if (this.Visible == false)
                this.Visible = true;

            this.labelControl1.Text = text;
            this.labelControl1.Refresh();
        }
        public void CloseSplash()
        {
            this.Close();
        }

        #endregion

        private void SplashForm_Shown(object sender, EventArgs e)
        {
            this.Location = new Point(MainForm.Location.X + (MainForm.Width - this.Width) / 2, MainForm.Location.Y + (MainForm.Height - this.Height) / 2);
        }
    }
}
